<template>
    <!-- 将最外层容器改为 el-container 确保布局正确 -->
    <el-container class="homepage-container">
      <!-- 顶部导航栏 -->
      <el-header class="header" height="80px">
        <div class="header-content">
          <div class="logo">
            <!-- 使用 require 正确加载图片 -->
            <img 
              :src="require('@/assets/logo.png')" 
              alt="logo" 
              class="logo-img" 
            />
            <h1 class="title">现代教育技术智慧平台</h1>
          </div>
          <el-menu
            mode="horizontal"
            background-color="#2c3e50"
            text-color="#fff"
            active-text-color="#409EFF"
            class="nav-menu"
          >
            <!-- 添加 router 属性支持路由跳转 -->
            <el-menu-item index="1" @click="$router.push('/')">首页</el-menu-item>
            <el-menu-item index="2">课程中心</el-menu-item>
            <el-menu-item index="3">资源库</el-menu-item>
            <el-menu-item index="4">数据分析</el-menu-item>
            <el-menu-item index="5">个人中心</el-menu-item>
          </el-menu>
        </div>
      </el-header>
  
      <!-- 主内容区域 -->
      <el-main class="main-content">
        <!-- 轮播图优化 -->
        <el-carousel 
          :interval="5000" 
          height="400px" 
          indicator-position="outside"
        >
          <el-carousel-item 
            v-for="item in 3" 
            :key="item"
          >
            <!-- 使用 require 动态加载图片 -->
            <img
              :src="require(`@/assets/banner${item}.png`)"
              alt="banner"
              class="carousel-img"
            />
          </el-carousel-item>
        </el-carousel>
  
        <!-- 功能模块 -->
        <div class="function-modules">
          <h2 class="module-title">核心功能</h2>
          <el-row :gutter="20">
            <el-col 
              v-for="(title, index) in moduleTitles" 
              :key="index"
              :xs="24" 
              :sm="12" 
              :md="8" 
              :lg="6"
            >
              <el-card class="module-card" shadow="hover">
                <div class="module-icon">
                  <!-- 使用 Element Plus 图标组件 -->
                  <el-icon :size="40" color="#409EFF">
                    <component :is="iconComponents[index]" />
                  </el-icon>
                </div>
                <h3 class="module-name">{{ title }}</h3>
                <p class="module-desc">智能化教学管理解决方案</p>
              </el-card>
            </el-col>
          </el-row>
        </div>
      </el-main>
  
      <!-- 页脚 -->
      <el-footer class="footer" height="60px">
        <div class="footer-content">
          <p>© 2025 现代教育技术智慧平台 xxxxx</p>
        </div>
      </el-footer>
    </el-container>
  </template>
  
  <script>
  // 按需引入 Element Plus 图标
  import { 
    Monitor,
    Collection,
    DataAnalysis,
    User 
  } from '@element-plus/icons-vue'
  
  export default {
    name: 'HomePage',
    data() {
      return {
        moduleTitles: [
          '智能课程管理',
          '教学资源中心',
          '学习数据分析',
          '教师发展平台'
        ],
        // 图标组件数组
        iconComponents: [Monitor, Collection, DataAnalysis, User]
      }
    },
    mounted() {
      document.title = "现代教育技术智慧平台"
    }
  }
  </script>
  
  <style scoped>
  /* 新增响应式样式 */
  @media (max-width: 768px) {
    .header-content {
      flex-direction: column;
      padding: 10px 0;
    }
  
    .nav-menu {
      margin-top: 10px;
    }
  
    .title {
      font-size: 18px !important;
    }
  
    .el-carousel {
      height: 250px !important;
    }
  }
  
  .homepage-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }
  
  .header {
    background-color: #2c3e50;
    padding: 0 20px;
  }
  
  .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
  }
  
  .logo {
    display: flex;
    align-items: center;
  }
  
  .logo-img {
    width: 50px;
    height: 50px;
    margin-right: 15px;
  }
  
  .title {
    color: #fff;
    font-size: 24px;
    margin: 0;
  }
  
  .nav-menu {
    border-bottom: none;
  }
  
  .main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
  }
  
  .carousel-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
  }
  
  .function-modules {
    margin-top: 40px;
  }
  
  .module-title {
    text-align: center;
    color: #2c3e50;
    font-size: 28px;
    margin-bottom: 30px;
  }
  
  .module-card {
    margin-bottom: 20px;
    text-align: center;
    transition: transform 0.3s;
    border: none;
  }
  
  .module-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
  
  .module-icon {
    margin: 20px 0;
  }
  
  .module-name {
    color: #303133;
    font-size: 18px;
    margin: 10px 0;
    font-weight: 500;
  }
  
  .module-desc {
    color: #909399;
    font-size: 14px;
    line-height: 1.5;
  }
  
  .footer {
    background-color: #2c3e50;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .footer-content {
    text-align: center;
    font-size: 14px;
    padding: 0 20px;
  }
  </style>